package com.lagou.rocketmq.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

@Service
public class RedisPoolFactory {

    @Autowired
    private RedisProperties properties;

    @Bean
    public JedisPool jedisPool(){
        JedisPoolConfig config = new JedisPoolConfig();
//        config.setMaxIdle(properties.getJedis().getPool().getMaxIdle());
//        config.setMaxTotal(properties.getJedis().getPool().getMaxActive());
//        config.setMaxWaitMillis(properties.getJedis().getPool().getMaxWait().toMillis());
        JedisPool jedisPool = new JedisPool(config, properties.getHost(), properties.getPort(), 100);
        return jedisPool;
    }
}
